#include <clocale>
#include "../../../Include/Base/WizBase.hpp"

namespace Wiz
{
	///////////////////////////////////////////////////
	::Wiz::Bool::Type WCharStrToMultiBytesStr(::Wiz::String::Out MBS, ::Wiz::WString::In WS, ::Wiz::Char::InPtr CP/*CodePage*/)
	{
		::Wiz::Bool::Type Result = ::Wiz::Bool::True;
		::Wiz::Char::ConstPtr OldCP = setlocale(LC_ALL, CP);
		::Wiz::WString::Type::tSize SrcSize = wcstombs(WIZ_NULLPTR, WS.GetCStr(), 0);
		MBS.Resize(SrcSize);
		if (SrcSize != wcstombs(MBS.GetBuffer(), WS.GetCStr(), SrcSize))
		{
			MBS.Clear();
			Result = ::Wiz::Bool::False;
		}
		setlocale(LC_ALL, OldCP);
		return Result;
	}
	::Wiz::Bool::Type MultiBytesStrToWCharStr(::Wiz::WString::Out WS, ::Wiz::String::In MBS, ::Wiz::Char::InPtr CP/*CodePage*/)
	{
		::Wiz::Bool::Type Result = ::Wiz::Bool::True;
		::Wiz::Char::ConstPtr OldCP = setlocale(LC_ALL, CP);
		::Wiz::String::Type::tSize SrcSize = mbstowcs(WIZ_NULLPTR, MBS.GetCStr(), 0);
		WS.Resize(SrcSize);
		if (SrcSize != mbstowcs(WS.GetBuffer(), MBS.GetCStr(), SrcSize))
		{
			WS.Clear();
			Result = ::Wiz::Bool::False;
		}
		setlocale(LC_ALL, OldCP);
		return Result;
	}
	///////////////////////////////////////////////////



    //////////////////////////////////////////////////////////////////////////
} /// end of namespace Wiz
